# -*- encoding:utf-8 -*-
"""
@作者：ven
@文件名：activity.py
@时间：2023-07-18  16:37
@文档说明:
"""
from common.baseApi import BaseAPI


class Coupon(BaseAPI):
    pass


class Activity(BaseAPI):
    pass


data = {'onlineType=probation': '试用会员',
        'monthly': '月度会员',
        'quarter': '季度会员',
        'year': '年度会员',
        'permanent': '永久大会员'
        }

if __name__ == '__main__':
    # 平台token
    token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuYmYiOjE2ODk5MjI1OTksImV4cCI6MTY4OTkzNjk5OSwiYXV0aFR5cGUiOiJQQyIsImlhdCI6MTY4OTkyMjU5OSwidXNlcklkIjoxMCwidXNlcm5hbWUiOiJyb290In0.pZZvJm12W9So37pLPhpoamPbkdzFpDxSFEleuBYKj1k'
    signMsg = 'dc6a51fd422c02ea198d4209b8670fa4'



    while True:
        _input = int(input('1:新增优惠券;2:新增活动;3:报名'))
        if _input == 1:
            #新增优惠券
            ObjCoupon = Coupon(inToken=token, signMsg=signMsg)

            for key, value in data.items():
                # 新增线上优惠券
                '''
                payload = {"name": "月体验券",
                   "assertType": "ONLINE",
                   "onlineType": "monthly",
                   "limitGet": "1", "inventory": "3",
                   "money": "",
                   "startDate": "2023-07-18 00:00:00",
                   "endDate": "2023-07-31 23:59:59",
                   "type": "ONLINE",
                   "time": ["2023-07-18 00:00:00", "2023-07-31 23:59:59"],
                   "receiveAssertDays": "", "offlineMoney": ""}
                '''
                payload = {"name": value,
                           "assertType": "ONLINE",
                           "onlineType": key,
                           "limitGet": "1", "inventory": "3",
                           "money": "",
                           "startDate": "2023-07-18 00:00:00",
                           "endDate": "2023-07-31 23:59:59",
                           "type": "ONLINE",
                           "time": ["2023-07-18 00:00:00", "2023-07-31 23:59:59"],
                           "receiveAssertDays": "", "offlineMoney": ""}
                # res = ObjCoupon.add(json=payload)
                # print(res.json())
            #新增线下优惠券
            for item in [1000,2000,3000]:
                offLinePayload = {"name":f"线下优惠券{item}元",
                                  "assertType":"ONLINE",
                                  "onlineType":"",
                                  "limitGet":"1",
                                  "inventory":"3",
                                  "money":f"{item}",
                                  "startDate":"2023-07-18 00:00:00",
                                  "endDate":"2023-08-31 23:59:59",
                                  "type":"OFFLINE",
                                  "time":["2023-07-18 00:00:00","2023-08-31 23:59:59"],
                                  "receiveAssertDays":"","offlineMoney":""}
                res = ObjCoupon.add(json=offLinePayload)
                print(res.json())

        elif _input == 2:
            #新增活动
            ObjActivity = Activity(inToken=token, signMsg=signMsg)
            payload = {"activityEndTime": "2023-07-22 23:59:59",
                       "activityStartTime": "2023-07-22 00:00:00",
                       "enrollEndTime": "2023-07-21 23:59:59",
                       "enrollStartTime": "2023-07-21 00:00:00",
                       "name": "心动的信号2",
                       "desc": "详情...",
                       "activityTarget": "2",
                       "scale": "3",
                       "targetType": "COUNT_UPLOAD_IMAGE",
                       "activityCouponEdit": None,
                       "apply": ["2023-07-18 00:00:00", "2023-07-18 23:59:59"],
                       "activity": ["2023-07-19 00:00:00", "2023-07-19 23:59:59"]}
            res = ObjActivity.add(json=payload)
            print(res.json())



